package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.CategoryBrandMapper;
import com.atguigu.spzx.manager.service.CategoryBrandService;
import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.spzx.model.entity.product.CategoryBrand;
import com.atguigu.spzx.model.vo.product.CategoryBrandVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LT
 * @create 2024-03-17-17:06
 */
@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {

    @Resource
    CategoryBrandMapper categoryBrandMapper;

    @Override
    public PageInfo<CategoryBrandVo> list(Integer pageNum, Integer pageSize, CategoryBrand categoryBrand) {
        PageHelper.startPage(pageNum,pageSize);
        List<CategoryBrandVo> list = categoryBrandMapper.selectPage(categoryBrand);
        PageInfo<CategoryBrandVo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void save(CategoryBrand categoryBrand) {
        categoryBrandMapper.save(categoryBrand);
    }

    @Override
    public void delete(List<Long> asList) {
        categoryBrandMapper.delete(asList);
    }

    @Override
    public CategoryBrand getById(Long id) {
        return categoryBrandMapper.getById(id);
    }

    @Override
    public void update(CategoryBrand categoryBrand) {
        categoryBrandMapper.update(categoryBrand);
    }

    @Override
    public List<Brand> GetBrandByCategoryId(Long categoryId) {
        return categoryBrandMapper.selectBrandsByC3id(categoryId);
    }
}
